<?php
define('ROOT_PATH','./');
define('TEMPLATE_DIR','client/');
require_once(ROOT_PATH.'code/bean/config.inc.php');
require_once(ROOT_PATH.'code/class/client/class.client_user.php');
require_once(ROOT_PATH.'code/class/client/class.client_send.php');
require_once(ROOT_PATH.'code/bean/smarty.config.inc.php');
require_once(ROOT_PATH.'code/bean/db_config.inc.php');
require_once(ROOT_PATH.'code/class/client/class.union.php');
$user=new client_user();
$session=check_login();
if(!$_COOKIE['tovy_login'])
{
	js_alert('请先登录',1,'index.php');
}
ini_set('display_errors',0);
// Unicode 解码
function _unescape ( $str, $charCode = null )
{
	if ( is_null ( $charCode ) )
	{
		$charCode = 'UTF-8';
	}

	$text = preg_replace_callback ( "/%u[0-9A-Za-z]{4}/", toUtf8, $str );
	return mb_convert_encoding ( $text, $charCode, 'utf-8' );
}

function toUtf8 ( $ar )
{
	$c='';
	foreach ( $ar as $val )
	{
		$val = intval ( substr ( $val, 2 ), 16 );
		if ( $val < 0x7F ) // 0000-007F
		{
			$c .= chr ( $val );
		}
		elseif ( $val < 0x800 ) // 0080-0800
		{
			$c .= chr ( 0xC0 | ( $val / 64 ) );
			$c .= chr ( 0x80 | ( $val % 64 ) );
		}
		else // 0800-FFFF
		{
			$c .= chr ( 0xE0 | ( ( $val / 64) / 64 ) );
			$c .= chr ( 0x80 | ( ( $val / 64 ) % 64 ) );
			$c .= chr ( 0x80 | ( $val % 64 ) );
		}
	}
	return $c;
}

if(isset($_GET['title'])) {
	$title=$_GET['title'];
	if(isset($_GET['encode']) && $_GET['encode']=='escape') {
		$title=_unescape($title);
	}
	$tpl->assign('tmp_title',$title);
}
if(isset($_GET['content'])) {
	$content=$_GET['content'];
	if(isset($_GET['encode']) && $_GET['encode']=='escape') {
		$content=_unescape($content);
	}
	$tpl->assign('tmp_content',$content);
}

$send=new send();


$objUnion = new union();
$siteInfo = $objUnion->getSiteInfo();
$newsList = $objUnion->getNews(2,'',5);//平台新闻
$tpl->assign("nickname",$user->nick_name);
$tpl->assign('siteInfo',$siteInfo);
$tpl->assign('ptxw',$newsList);	//var_dump($newsList);


$tpl->assign('user',$user);
$tpl->assign('send',$send);
$tpl->assign('left_user_info','tpl/left_user_info.tpl');
$tpl->display('send.html');
?>